﻿using DI.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using Microsoft.Practices.Unity;
using System.Web.Routing;
using Service;
using EF.Client.Provider;
using DI;

namespace Strawberry
{
    // Remarque : pour obtenir des instructions sur l'activation du mode classique IIS6 ou IIS7, 
    // visitez http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        //private static string connectionString = @"Data Source=10.10.145.1\SQLEXPRESS,1433;Initial Catalog=ecofast;User Id=boris;Password=boris";
        private static string connectionString = @"Data Source=tcp:u2cbx9xc2a.database.windows.net,1433;Initial Catalog=Strawberry;User Id=strawberry@u2cbx9xc2a;Password=Chevre123456";



        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            var container = new DiConfig().Container;
            UnityContainerHelper.Init(container);
            container.Resolve<IAppInitializer>().InitDB(connectionString);


            var factory = new UnityControllerFactory(container);
            ControllerBuilder.Current.SetControllerFactory(factory);

        }
    }
}